from manim import *


class math2(Scene):
    def construct(self):
        self.camera.background_color = BLACK  # 设置背景颜色
        self.camera.frame_width = 100  # 设置边框宽度
        self.camera.frame_height = 60  # 设置边框高度
        self.camera.pixel_height = 1080  # 设置像素高度
        self.camera.pixel_width = 1920  # 设置像素宽度
        self.camera.center = ORIGIN  # 设置中心点位置
        self.camera.scale_factor = 1.0  # 设置缩放因子
        #设置横线
        for i in range(6*2+1):       
            dot1=Dot([-50,5*(i-6),0]).set_opacity(0.5)
            dot2=Dot([50,5*(i-6),0]).set_opacity(0.5)
            if i==6:
                line1=Line(dot1,dot2).set_color(BLUE).set_opacity(0.5)
                line1.set_stroke(width=10)
            else:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
               
            self.add(dot1,dot2,line1)
        #设置竖线
        for i in range(10*2+1):        
            dot3=Dot([(i-10)*5,-30,0]).set_opacity(0.5)
            dot4=Dot([(i-10)*5,30,0]).set_opacity(0.5)
            if i==10:
                line2=Line(dot3,dot4).set_color(BLUE).set_opacity(0.5)
                line2.set_stroke(width=10)
            else:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
            self.add(dot3,dot4,line2)
        #设置三个点
        dot1 = Dot(radius=1, color=RED)  
        dot1.move_to([-47.5,27.5,0]) 
        dot2 = Dot(radius=1, color=YELLOW)  
        dot2.move_to([-42.5,27.5,0])  
        dot3 = Dot(radius=1, color=GREEN)  
        dot3.move_to([-37.5,27.5,0])   
        #特征碎片文本

        text0=MarkupText("<b><i>Summary：</i></b>",color=PINK).scale(5.0).move_to([-35,17.5,0])
        text1=Tex(r"\text{收获1张特征碎片}",color=YELLOW
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0, 0, 0])
        self.play(Write(text0),Create(text1))
        text2=Tex(r"\text{1张特征碎片}",color=YELLOW
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0, 0, 0])
        self.play(Transform(text1,text2),Uncreate(text1),text2.animate.move_to([-17,17.5,0]),run_time=1)
        #文本
        text3=Tex(r"\text{计算高阶导数}"
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-35, 0, 0])
        self.play(Write(text3))
        #箭头标记
        arrow = Arrow(start=[-25,2.5,0],end=[-20,10,0], color=RED
                       , stroke_width=40, tip_length=1)
        self.play(Create(arrow))
        #文本
        text4=Tex(r"$f^{\left( n\right) }\left( x\right) $"
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-14, 10, 0])
        self.play(Write(text4))
        #箭头标记
        arrow1 = Arrow(start=[-25,-2.5,0],end=[-20,-5,0], color=RED
                       , stroke_width=40, tip_length=1)
        self.play(Create(arrow1))
        #文本
        text5=Tex(r"$f^{\left( n\right) }\left( x_{o}\right) $"
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-14, -5, 0])
        self.play(Write(text5))
        #框框闪动
        rectangle=Rectangle(color=BLUE,fill_opacity=0.0,width=10,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle.move_to([-14, 10, 0])
        self.play(Create(rectangle))
        self.play(FadeOut(rectangle))
         #箭头引出
        arrow30 = Arrow(start=[-7.5,10,0],end=[0,10,0], color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(arrow30))
        #文本2
        text29 = Tex(r"\text{找规律}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([7.5,10,0])
        self.play(Write(text29))

        #框框闪动
        rectangle1=Rectangle(color=BLUE,fill_opacity=0.0,width=10,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle1.move_to([-14, -5, 0])
        self.play(Create(rectangle1))
        self.play(FadeOut(rectangle1))
        #箭头1引出
        arrow28 = Arrow(start=[-7.5,-3,0],end=[0,2.5,0], color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(arrow28))
        #文本3
        text27 = Tex(r"\text{奇偶性}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([7.5,2.5,0])
        self.play(Write(text27))

        #箭头2引出
        arrow26 = Arrow(start=[-7.5,-5,0],end=[0,-2.5,0], color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(arrow26))
        #文本4
        text25 = Tex(r"\text{莱布尼兹}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([7.5,-2.5,0])
        self.play(Write(text25))

        #箭头3引出
        arrow24 = Arrow(start=[-7.5,-7,0],end=[0,-7.5,0], color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(arrow24))
        #文本5
        text23= Tex(r"\text{泰勒展开}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([7.5,-7.5,0])
        self.play(Write(text23))

        #箭头4引出
        arrow22 = Arrow(start=[-7.5,-9,0],end=[0,-12.5,0], color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(arrow22)) 
        #文本6
        text21= Tex(r"\text{构造递推}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([7.5,-12.5,0])
        self.play(Write(text21))
        #框框+文本
        rectangle20=Rectangle(color=RED,fill_opacity=0.0,width=17,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle20.move_to([-35, 0, 0])
        self.play(Create(rectangle20))
        text19=Tex(r"\text{题型}",color=BLUE
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(rectangle20,UP,buff=1)
        self.play(Write(text19))

        rectangle18=Rectangle(color=RED,fill_opacity=0.0,width=11,height=24
                            ,stroke_color=PURPLE,stroke_width=20)
        rectangle18.move_to([-14, 1, 0])
        self.play(Create(rectangle18))
        text17=Tex(r"\text{特征}",color=BLUE
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(rectangle18,DOWN,buff=1)
        self.play(Write(text17))

        rectangle16=Rectangle(color=RED,fill_opacity=0.0,width=13,height=30
                            ,stroke_color=YELLOW,stroke_width=20)
        rectangle16.move_to([7.5, -2, 0])
        self.play(Create(rectangle16))
        text15=Tex(r"\text{对应解法}",color=BLUE
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(rectangle16,DOWN,buff=1)
        self.play(Write(text15))

        rectangle14=Rectangle(color=RED,fill_opacity=0.0,width=65,height=36
                            ,stroke_color=GREEN_E,stroke_width=20)
        rectangle14.move_to([-15, -3, 0])
        self.play(Create(rectangle14))
        text13=Tex(r"\text{解题思路结构化}",color=BLUE
                  ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(rectangle14,DOWN,buff=1)
        self.play(Write(text13))


        

